Telegram Group & Telegram Channel
Common techniques for using the set() function in Python:

1. Create a set from a list:

my_list = [1, 2, 2, 3, 3, 3]
my_set = set(my_list)


2.Add an item to a set:

my_set = {1, 2, 3}
my_set.add(4)


3.Remove an item from a set by its value:

my_set = {1, 2, 3}
my_set.remove(3)


4.Check if an item is in a set:

my_set = {1, 2, 3}
if 3 in my_set:
print("The item is in the set.")


5.Get the length of a set:

my_set = {1, 2, 3}
set_length = len(my_set)


6.Loop through the items in a set:

my_set = {1, 2, 3}
for item in my_set:
print(item)


7.Get the union of two sets:

set1 = {1, 2, 3}
set2 = {3, 4, 5}
union_set = set1.union(set2)


8.Get the intersection of two sets:

set1 = {1, 2, 3}
set2 = {3, 4, 5}
intersection_set = set1.intersection(set2)

Share and Support
@Python_Codes



tg-me.com/python_codes/252
Create:
Last Update:

Common techniques for using the set() function in Python:

1. Create a set from a list:

my_list = [1, 2, 2, 3, 3, 3]
my_set = set(my_list)


2.Add an item to a set:

my_set = {1, 2, 3}
my_set.add(4)


3.Remove an item from a set by its value:

my_set = {1, 2, 3}
my_set.remove(3)


4.Check if an item is in a set:

my_set = {1, 2, 3}
if 3 in my_set:
print("The item is in the set.")


5.Get the length of a set:

my_set = {1, 2, 3}
set_length = len(my_set)


6.Loop through the items in a set:

my_set = {1, 2, 3}
for item in my_set:
print(item)


7.Get the union of two sets:

set1 = {1, 2, 3}
set2 = {3, 4, 5}
union_set = set1.union(set2)


8.Get the intersection of two sets:

set1 = {1, 2, 3}
set2 = {3, 4, 5}
intersection_set = set1.intersection(set2)

Share and Support
@Python_Codes

BY Python Codes


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/python_codes/252

View MORE
Open in Telegram


Python Codes Telegram | DID YOU KNOW?

Date: |

Telegram Gives Up On Crypto Blockchain Project

Durov said on his Telegram channel today that the two and a half year blockchain and crypto project has been put to sleep. Ironically, after leaving Russia because the government wanted his encryption keys to his social media firm, Durov’s cryptocurrency idea lost steam because of a U.S. court. “The technology we created allowed for an open, free, decentralized exchange of value and ideas. TON had the potential to revolutionize how people store and transfer funds and information,” he wrote on his channel. “Unfortunately, a U.S. court stopped TON from happening.”

For some time, Mr. Durov and a few dozen staffers had no fixed headquarters, but rather traveled the world, setting up shop in one city after another, he told the Journal in 2016. The company now has its operational base in Dubai, though it says it doesn’t keep servers there.Mr. Durov maintains a yearslong friendship from his VK days with actor and tech investor Jared Leto, with whom he shares an ascetic lifestyle that eschews meat and alcohol.

Python Codes from ye


Telegram Python Codes
FROM USA